<!DOCTYPE html>
<html ng-app="demoApp">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Layout 布局 - ng-components-ui</title>
    <link rel="stylesheet" href="../dist/ng-components.css" />
    <style>
      * {
        box-sizing: border-box;
      }

      body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
        margin: 0;
        padding: 0;
        background: #f5f5f5;
      }

      .header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 30px 40px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      }

      .header h1 {
        margin: 0 0 10px 0;
        font-size: 32px;
      }

      .header p {
        margin: 0;
        opacity: 0.9;
        font-size: 16px;
      }

      .back-link {
        display: inline-block;
        margin-top: 15px;
        color: white;
        text-decoration: none;
        padding: 8px 16px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        transition: background 0.2s;
      }

      .back-link:hover {
        background: rgba(255, 255, 255, 0.3);
      }

      .container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 40px;
      }

      .demo-section {
        background: white;
        padding: 30px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        margin-bottom: 30px;
      }

      .demo-section h2 {
        margin: 0 0 20px 0;
        color: #333;
        font-size: 20px;
        border-bottom: 2px solid #667eea;
        padding-bottom: 10px;
      }

      .demo-section h3 {
        margin: 20px 0 15px 0;
        color: #555;
        font-size: 16px;
        font-weight: 600;
      }

      .demo-section p {
        color: #666;
        line-height: 1.6;
        margin: 0 0 15px 0;
      }

      .demo-box {
        margin: 20px 0;
      }

      .demo-col {
        background: #667eea;
        color: white;
        text-align: center;
        padding: 16px 0;
        border-radius: 4px;
        margin-bottom: 8px;
      }

      .demo-col-dark {
        background: #764ba2;
      }

      .code-block {
        background: #f7fafc;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        padding: 15px;
        margin: 10px 0;
        font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
        font-size: 12px;
        overflow-x: auto;
      }

      .code-block code {
        color: #2d3748;
      }

      .feature-list {
        background: #f7fafc;
        border-left: 4px solid #667eea;
        padding: 15px 20px;
        margin: 20px 0;
      }

      .feature-list ul {
        margin: 0;
        padding-left: 20px;
      }

      .feature-list li {
        color: #4a5568;
        margin: 8px 0;
        line-height: 1.6;
      }

      .row-bg {
        background: #f0f2f5;
        padding: 10px;
        border-radius: 4px;
        margin: 20px 0;
      }
    </style>
  </head>
  <body ng-controller="DemoController">
    <div class="header">
      <h1>Layout 布局组件</h1>
      <p>24 栅格系统，快速实现响应式布局</p>
      <a href="home.html" class="back-link">← 返回主页</a>
    </div>

    <div class="container">
      <div class="demo-section">
        <h2>Layout 布局 (ng-row / ng-col)</h2>

        <div class="feature-list">
          <strong>功能特性:</strong>
          <ul>
            <li>24 栅格布局系统</li>
            <li>Flex 布局，支持水平和垂直对齐</li>
            <li>Gutter 间距控制</li>
            <li>响应式断点（xs, sm, md, lg, xl）</li>
            <li>Offset 偏移</li>
            <li>简洁的 API，易于使用</li>
          </ul>
        </div>

        <h3>1. 基础布局</h3>
        <p>使用 <code>span</code> 属性定义列宽（1-24）</p>

        <div class="demo-box">
          <ng-row>
            <ng-col span="24"><div class="demo-col">span-24</div></ng-col>
          </ng-row>

          <ng-row>
            <ng-col span="12"><div class="demo-col">span-12</div></ng-col>
            <ng-col span="12"><div class="demo-col-dark">span-12</div></ng-col>
          </ng-row>

          <ng-row>
            <ng-col span="8"><div class="demo-col">span-8</div></ng-col>
            <ng-col span="8"><div class="demo-col-dark">span-8</div></ng-col>
            <ng-col span="8"><div class="demo-col">span-8</div></ng-col>
          </ng-row>

          <ng-row>
            <ng-col span="6"><div class="demo-col">span-6</div></ng-col>
            <ng-col span="6"><div class="demo-col-dark">span-6</div></ng-col>
            <ng-col span="6"><div class="demo-col">span-6</div></ng-col>
            <ng-col span="6"><div class="demo-col-dark">span-6</div></ng-col>
          </ng-row>
        </div>

        <div class="code-block">
          <code>
&lt;ng-row&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="12"&gt;左侧&lt;/ng-col&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="12"&gt;右侧&lt;/ng-col&gt;<br>
&lt;/ng-row&gt;
          </code>
        </div>

        <h3>2. 分栏间隔</h3>
        <p>使用 <code>gutter</code> 属性设置列之间的间距（像素）</p>

        <div class="demo-box">
          <div class="row-bg">
            <ng-row gutter="16">
              <ng-col span="6"><div class="demo-col">gutter-16</div></ng-col>
              <ng-col span="6"><div class="demo-col-dark">gutter-16</div></ng-col>
              <ng-col span="6"><div class="demo-col">gutter-16</div></ng-col>
              <ng-col span="6"><div class="demo-col-dark">gutter-16</div></ng-col>
            </ng-row>
          </div>

          <div class="row-bg">
            <ng-row gutter="32">
              <ng-col span="8"><div class="demo-col">gutter-32</div></ng-col>
              <ng-col span="8"><div class="demo-col-dark">gutter-32</div></ng-col>
              <ng-col span="8"><div class="demo-col">gutter-32</div></ng-col>
            </ng-row>
          </div>
        </div>

        <div class="code-block">
          <code>
&lt;ng-row gutter="16"&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="6"&gt;列1&lt;/ng-col&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="6"&gt;列2&lt;/ng-col&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="6"&gt;列3&lt;/ng-col&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="6"&gt;列4&lt;/ng-col&gt;<br>
&lt;/ng-row&gt;
          </code>
        </div>

        <h3>3. 列偏移</h3>
        <p>使用 <code>offset</code> 属性设置列的左侧间隔格数</p>

        <div class="demo-box">
          <ng-row>
            <ng-col span="8"><div class="demo-col">span-8</div></ng-col>
            <ng-col span="8" offset="8"><div class="demo-col-dark">offset-8</div></ng-col>
          </ng-row>

          <ng-row>
            <ng-col span="6" offset="6"><div class="demo-col">offset-6 span-6</div></ng-col>
            <ng-col span="6" offset="6"><div class="demo-col-dark">offset-6 span-6</div></ng-col>
          </ng-row>

          <ng-row>
            <ng-col span="12" offset="6"><div class="demo-col">offset-6 span-12</div></ng-col>
          </ng-row>
        </div>

        <div class="code-block">
          <code>
&lt;ng-row&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="8"&gt;列1&lt;/ng-col&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="8" offset="8"&gt;列2（偏移8格）&lt;/ng-col&gt;<br>
&lt;/ng-row&gt;
          </code>
        </div>

        <h3>4. 对齐方式</h3>
        <p>使用 <code>justify</code> 和 <code>align</code> 属性设置对齐方式</p>

        <div class="demo-box">
          <p><strong>水平对齐 (justify):</strong></p>

          <div class="row-bg">
            <ng-row justify="start">
              <ng-col span="6"><div class="demo-col">justify-start</div></ng-col>
            </ng-row>
          </div>

          <div class="row-bg">
            <ng-row justify="center">
              <ng-col span="6"><div class="demo-col">justify-center</div></ng-col>
            </ng-row>
          </div>

          <div class="row-bg">
            <ng-row justify="end">
              <ng-col span="6"><div class="demo-col">justify-end</div></ng-col>
            </ng-row>
          </div>

          <div class="row-bg">
            <ng-row justify="space-between">
              <ng-col span="6"><div class="demo-col">space-between</div></ng-col>
              <ng-col span="6"><div class="demo-col-dark">space-between</div></ng-col>
            </ng-row>
          </div>

          <div class="row-bg">
            <ng-row justify="space-around">
              <ng-col span="6"><div class="demo-col">space-around</div></ng-col>
              <ng-col span="6"><div class="demo-col-dark">space-around</div></ng-col>
            </ng-row>
          </div>
        </div>

        <div class="code-block">
          <code>
&lt;!-- 水平对齐 --&gt;<br>
&lt;ng-row justify="center"&gt;...&lt;/ng-row&gt;<br>
&lt;ng-row justify="space-between"&gt;...&lt;/ng-row&gt;<br>
<br>
&lt;!-- 垂直对齐 --&gt;<br>
&lt;ng-row align="middle"&gt;...&lt;/ng-row&gt;
          </code>
        </div>

        <h3>5. 响应式布局</h3>
        <p>使用 <code>xs, sm, md, lg, xl</code> 属性设置不同屏幕下的列宽</p>

        <div class="demo-box">
          <ng-row gutter="16">
            <ng-col span="24" sm="12" md="8" lg="6">
              <div class="demo-col">响应式列 1</div>
            </ng-col>
            <ng-col span="24" sm="12" md="8" lg="6">
              <div class="demo-col-dark">响应式列 2</div>
            </ng-col>
            <ng-col span="24" sm="12" md="8" lg="6">
              <div class="demo-col">响应式列 3</div>
            </ng-col>
            <ng-col span="24" sm="12" md="8" lg="6">
              <div class="demo-col-dark">响应式列 4</div>
            </ng-col>
          </ng-row>
        </div>

        <div class="code-block">
          <code>
&lt;ng-row gutter="16"&gt;<br>
&nbsp;&nbsp;&lt;ng-col span="24" sm="12" md="8" lg="6"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;移动端占满，平板占1/2，桌面占1/3，大屏占1/4<br>
&nbsp;&nbsp;&lt;/ng-col&gt;<br>
&lt;/ng-row&gt;<br>
<br>
&lt;!-- 也可以使用对象形式 --&gt;<br>
&lt;ng-col xs="{span: 24, offset: 0}" md="{span: 12, offset: 6}"&gt;...&lt;/ng-col&gt;
          </code>
        </div>

        <h3>6. 综合示例</h3>
        <p>结合各种属性实现复杂布局</p>

        <div class="demo-box">
          <div class="row-bg">
            <ng-row gutter="20" justify="space-between" align="middle">
              <ng-col span="24" md="8">
                <div class="demo-col" style="min-height: 80px; line-height: 80px;">
                  响应式 + 对齐
                </div>
              </ng-col>
              <ng-col span="24" md="8">
                <div class="demo-col-dark">
                  带间距布局
                </div>
              </ng-col>
              <ng-col span="24" md="8">
                <div class="demo-col" style="min-height: 120px; line-height: 120px;">
                  高度不同也能对齐
                </div>
              </ng-col>
            </ng-row>
          </div>
        </div>

        <h3>7. 断点说明</h3>
        <div class="code-block">
          <code>
xs: &lt; 768px    (手机)<br>
sm: ≥ 768px    (平板)<br>
md: ≥ 992px    (桌面)<br>
lg: ≥ 1200px   (大桌面)<br>
xl: ≥ 1920px   (超大桌面)
          </code>
        </div>
      </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/angular-strap@2.3.12/dist/angular-strap.min.js"></script>
    <script src="../dist/ng-components.js"></script>
    <script>
      angular.module("demoApp", ["ngComponents"]).controller("DemoController", function ($scope) {
        // Layout demo 不需要特殊逻辑
      });
    </script>
  </body>
</html>
